package com.hardson.toolkit.listcomparator;

public class StringListComparator<T> extends ListComparator<T> {

	public StringListComparator() {
	}

	/**
	 * @deprecated the parameter clazz is no longer effective
	 * @param colName
	 * @param clazz
	 * @param order
	 */
	@Deprecated
	public StringListComparator(final String colName, final Class<?> clazz, final int order) {
		this.colName = colName;
		this.cl = clazz;
		this.order = order;
	}

	public StringListComparator(final String colName, final int order) {
		this.colName = colName;
		this.order = order;
	}

	@Override
	public int compare(final T t1, final T t2) {
		T swapObj[] = this.swap(t1, t2);
		Object val0 = this.getValueObj(swapObj[0]);
		Object val1 = this.getValueObj(swapObj[1]);
		Integer result = this.compareNull(val0, val1);
		if (result != null) {
			return result;
		}
		String cmp0 = val0.toString();
		String cmp1 = val1.toString();

		return cmp0.compareTo(cmp1);
	}

}
